<!--
 * @Author: your name
 * @Date: 2022-10-28 10:21:52
 * @LastEditTime: 2023-03-13 15:42:19
 * @LastEditors: yuhan
 * @Description: 
 * @FilePath: \apiadmin\src\App.vue
-->
<template>
  <el-config-provider :locale="localLanguage">
    <el-scrollbar height="100vh" ref="scroll">
      <router-view></router-view>
    </el-scrollbar>
  </el-config-provider>
</template>

<script setup>
import { onMounted, computed, ref, watch } from "vue";
import { useStore } from "vuex";

import i18n from "@/locales";
import { useRouter } from "vue-router";
import { formatTime } from "@/utils/index.js";
const locale = i18n.global.locale;

const store = useStore();

const localLanguage = computed(() => {
  const isDev = process.env.NODE_ENV === "development";
  if (isDev) return i18n.global.messages.value[locale.value];
  else return i18n.global.messages[locale];
});

const scroll = ref(null);

const router = useRouter();

const logArrFn = (logArr) => {
  console.log("logArr", logArr);
  eval(
    "console.log(`%c %c${logArr[0].label}\n %c${logArr[1].label}\n %c${logArr[2].label}\n %c${logArr[3].label}\n %c${logArr[4].label}\n %c${logArr[5].label}\n %c${logArr[6].label}%c${logArr[7].label}`, '', `${logArr[0].style}`, `${logArr[1].style}`, `${logArr[2].style}`, `${logArr[3].style}`, `${logArr[4].style}`, `${logArr[5].style}`, `${logArr[6].style}`, `${logArr[7].style}`)"
  );
};
watch(
  () => router.currentRoute.value,
  () => {
    scroll.value.setScrollTop(0);
  }
);
onMounted(() => {
  store.dispatch("setting/setIsDev", process.env.NODE_ENV === "development");
  logArrFn([
    {
      label: "funSwitch平台",
      style: "color: #f28b68; font-size: 16px; font-weight: 600; width: 100%;",
    },
    {
      label: '授权信息：授权"广州凡拓数字创意科技股份有限公司"永久使用此软件当前版本',
      style: "color: #35495e; font-size: 12px; line-height: 18px;",
    },
    {
      label: "版权声明：",
      style: "color: #35495e; font-size: 12px; line-height: 18px;",
    },
    {
      label: '1.funSwitch版权完全属于"广州凡拓数字创意科技股份有限公司"',
      style: "color: #35495e; font-size: 12px; line-height: 18px;",
    },
    {
      label: `2.当前基于funSwitch二次开发的项目所有权益属于"广州凡拓数字创意科技股份有限公司"独自所有`,
      style: "color: #35495e; font-size: 12px; line-height: 18px;",
    },
    {
      label: `编译日期：${formatTime(new Date(), "YYYY-MM-DD hh:mm:ss")}`,
      style: "color: #35495e; font-size: 12px; line-height: 18px;",
    },
    {
      label: `1.0.0`,
      style: "background: #35495e; padding: 4px; border-radius: 3px 0 0 3px; color: #fff;",
    },
    {
      label: `版本`,
      style: "background: #41b883; padding: 4px; border-radius: 0 3px 3px 0; color: #fff;",
    },
  ]);
});

// console.log 原模板
// const logObj = console['log'](
//   `%c %c\nfunSwitch平台\n%c\n授权信息：授权"广州凡拓数字创意科技股份有限公司"永久使用此软件当前版本%c\n版权声明：%c\n1.funSwitch版权完全属于"广州凡拓数字创意科技股份有限公司"%c\n2.当前基于funSwitch二次开发的项目所有权益属于"广州凡拓数字创意科技股份有限公司"独自所有\n%c\n编译日期：${formatTime(
//     new Date(),
//     'YYYY-MM-DD hh:mm:ss'
//   )}\n%c 1.0.0 %c 版本`,
//   `background-size: contain;
//   background-repeat: no-repeat;
//   color: transparent;`,
//   'color: #f28b68; font-size: 16px; font-weight: 600;',
//   'color: #35495e; font-size: 12px; margin-bottom: 10px;',
//   'color: #35495e; font-size: 12px; ',
//   'color: #35495e; font-size: 12px;',
//   'color: #35495e; font-size: 12px;',
//   'color: #35495e; font-size: 12px; margin-bottom: 10px;',
//   'background: #35495e; padding: 4px; border-radius: 3px 0 0 3px; color: #fff',
//   'background: #41b883; padding: 4px; border-radius: 0 3px 3px 0; color: #fff'
// );
</script>

<style lang="scss">
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  font-size: $base-font-size-default;
  color: #2c3e50;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
</style>
